﻿using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using net8.Helper;
using System.Text.Json.Serialization;

namespace net8.Controllers
{
    /// <summary>
    /// 高德接口
    /// </summary>
    [AllowAnonymous]
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class GaoDeController : ControllerBase
    {
        [HttpGet]
        public async Task GetDistrict()
        {
            string url = "https://restapi.amap.com/v3/config/district";

            Dictionary<string, string> dics = new Dictionary<string, string>
            {
                { "key", "c124c4dccb4997019de16b0d59c1cb5a" },
                { "subdistrict", "1" },
                { "keywords", "100000" }
            };

            var aaa = await HttpHelper.GetJsonAsync<GaoDeResult<List<Districts>>>(url, dics);
        }
    }

    public class GaoDeResult<T> : IHttpResult
    {
        ///// <summary>
        ///// 状态
        ///// </summary>
        [JsonPropertyName("status")]
        public string Status { get; set; }

        [JsonPropertyName("info")]
        public string Message { get; set; }

        public T districts { get; set; }
    }



    public class Districts
    {
        //public object[] citycode { get; set; }
        public string adcode { get; set; }
        public string name { get; set; }
        public string center { get; set; }
        public string level { get; set; }
        public List<Districts> districts { get; set; }
    }

}
